function checknull(str) {
	if (str == "") {
		return true;
	} else {
		return false;
	}
}
function checkmin(str, min) {
	if (str.getBytes() < min) {
		return true;
	} else {
		return false;
	}
}
function checkmax(str, max) {
	if (str.getBytes() > max) {
		return true;
	} else {
		return false;
	}
}
String.prototype.getBytes = function() {
	var cArr = this.match(/[^\x00-\xff]/ig);
	return this.length + (cArr == null ? 0 : cArr.length);
};
function checkln(str) {
	var valid = /^[a-zA-Z][0-9a-zA-Z]*$/;
	return (valid.test(str));
}
function checklandn(str) {
	var valid = /^[0-9a-zA-Z]*$/;
	return (valid.test(str));
}
function checkl(str) {
	var valid = /^[a-zA-Z]*$/;
	return (valid.test(str));
}
function checknumber(str) {
	var valid = /^[0-9]{4}$/;
	return (valid.test(str));
}
function checkmail(str) {
	var valid = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return (valid.test(str));
}
function checkblankspace(str) {
	if (str.indexOf(" ") >= 0) {
		return true;
	}
	return false;
}
//换验证码
function changecaptcha() {
	var captchaimg = document.getElementById("capcode");
	captchaimg.src="CommonServlet?bean=Captcha&r="+Math.random()*100;
}
//验证验证码
function checkcaptcha(str) {
	var tipDiv = document.getElementById("tips");
	var cpfIpt = document.getElementById("captchaflag");
	if(!checkl(str)) {
		showMsg("captchamsg", "验证码错误");
		changecaptcha();
		cpfIpt.value = false;
		if (tipDiv!=null) {
			tipDiv.innerHTML = "验证码错误";
		}
		return;
	}
	var xmlhttp;
	if(window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}else{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4&&xmlhttp.status==200){
			var str2=xmlhttp.responseText.replace(/\s+/g,"");
			if(str2=="true"){
				cpfIpt.value = true;
				if (tipDiv!=null) {
					tipHide();
				}
				hiddMsg("captchamsg");
			}else{
				changecaptcha();
				cpfIpt.value = false;
				if (tipDiv!=null) {
					tipShow("验证码错误");
				}
				showMsg("captchamsg", "验证码错误");
			}
		}
	};
	xmlhttp.open("POST","CommonServlet?bean=ChatUserPo",true);
	xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xmlhttp.send("m=checkcaptcha&captcha="+str);
}

//根据id显示str信息
function showMsg(idStr, str) {
	var msgSpan = document.getElementById(idStr);
	if (msgSpan!=null) {
		msgSpan.className = "tip";
		msgSpan.innerHTML = str;
	}
}
function hiddMsg(idStr) {
	var msgSpan = document.getElementById(idStr);
	if (msgSpan!=null) {
		msgSpan.className = "tipHide";
	}
}